var CustomForm={};

CustomForm.baseUrl = window.location.origin;
CustomForm.search = function (table,where,callback) {
    var wheres = [];

    if(typeof where=="function"){
        callback = where;
        where = null;
    }else{
        var whereField = where.find("input:enabled");
        for(var i=0;i<whereField.length;i++){
            if($(whereField[i]).val()!=""){
                wheres.push(
                    {
                        "nameShort":$(whereField[i]).attr("name"),
                        "value":$(whereField[i]).val(),
                        "condition":$(whereField[i]).data("condition")
                    }
                );
            }
        }
    }
    jQuery.ajax({
        url:CustomForm.baseUrl+"/custom/data/list/"+table,
        type:"post",
        dataType:"json",
        contentType:"application/json",
        data:JSON.stringify(wheres),
        success:function(result){
            callback(result);
        },
        error:function (z,x,c) {
            console.log(z);
        }
    });
}